<%@page import="java.sql.SQLException"%>
<%@page import="java.rmi.RemoteException"%>
<%@page import="exception.NotLoggedInException"%>
<%@page import="java.util.LinkedList"%>
<%@page import="java.rmi.Naming"%>
<%@page import="server.ForumHandlerInt"%>
<%@page import="server.NotificationMsg"%>
<%@page import="java.util.Vector"%>
<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
    
<%!
public static int FRIEND_ADDED_POST = 0;
public static int CREATORS_TOPIC_UPDATED = 1;
public static int NEW_POST_IN_CURRENT_TOPIC = 2;
public static int FRIEND_UPDATED_POST = 3;
public static int POST_UPDATED_IN_CURRENT_TOPIC = 4;
public static int POST_DELETED_IN_CURRENT_TOPIC = 7;
public static int FRIEND_DELETED_POST = 8;

%>    
<NOTIFICATIONS>
<%@ include file="serverConnection.jsp" %>

<%

LinkedList<NotificationMsg> inbox = null;
try
{
	inbox = (forum.getNotificationMsgsNb((String)session.getAttribute("userName")));
	
	for (NotificationMsg nmsg:inbox)
	{
		//String reason = null;
		//switch (nmsg.getType())
		//{
		//	case 0 : reason = "Your friend added new post"; break;
		//	case 1 : reason = "New post added to one of your topics"; break;
		//	case 2 : reason = "New post has added to the topic that you are looking at"; break;
		//}
		%> 
		<MSG>
		   <REASON><%=nmsg.getType()%></REASON> 
		   <USER><%=nmsg.getUserName()%></USER>
		   <CREATOR><%=nmsg.getPost().getCreator().getUserName()%></CREATOR>
		   <FORUMID><%=nmsg.getForum().getId()%></FORUMID>
		   <FORUM><%=nmsg.getForum().getName()%></FORUM>
		   <TOPICID><%=nmsg.getTopic().getId()%></TOPICID>
		   <TOPIC><%=nmsg.getTopic().getTitle()%></TOPIC>
		   <POST><%=nmsg.getPost().getTitle() %></POST>
		   <POSTID><%=nmsg.getPost().getId() %></POSTID>
		   <POSTCONTENT><%=nmsg.getPost().getContent() %></POSTCONTENT>
		   <CREATION><%=nmsg.getPost().getCreationTime().toLocaleString() %></CREATION>
		   <EDITING><%=nmsg.getPost().getEditingTime().toLocaleString() %></EDITING>
		</MSG>
		
		<%
	}
	

}
catch(NotLoggedInException e)
{
	response.sendRedirect("loggin.jsp");
	response.flushBuffer();
	return;
}

catch(Exception u){
	   
	   response.sendError(response.SC_INTERNAL_SERVER_ERROR,
		"forum server is down");
	
		response.flushBuffer();
		return;
}

%> 

</NOTIFICATIONS>


